import jsonp from 'jsonp'

export default {
  name: 'Dingdan',
  data () {
    return {}
  },
  mounted () {
    jsonp('https://api.map.baidu.com/api?v=2.0&type=webgl&ak=7gIIsmhZ8jlaNG8MvA1GbVDAW1vp2VZI', {}, () => {
      // 初始化地图
      this.initMap()
    })
  },
  methods: {
    initMap () {
      const map = new window.BMapGL.Map('map')
      const point = new window.BMapGL.Point(116.404, 39.915)
      map.centerAndZoom(point, 15)
      // 开启滚轮缩放
      map.enableScrollWheelZoom(true)
      map.setHeading(64.5) // 设置地图旋转角度
      map.setTilt(73)
      const scaleCtrl = new window.BMapGL.ScaleControl() // 添加比例尺控件
      map.addControl(scaleCtrl)
      // 创建标记点
      const marker1 = new window.BMapGL.Marker(new window.BMapGL.Point(116.404, 39.925), {
        enableDragging: true
      })
      map.addOverlay(marker1)
    }
  }
}
